//
//  ZKQPointView.m
//  Test
//
//  Created by 张凯琦 on 16/5/19.
//  Copyright © 2016年 张凯琦. All rights reserved.
//

#import "ZKQPointView.h"

@interface ZKQPointView () <UIGestureRecognizerDelegate>

@end

@implementation ZKQPointView

+ (CGSize)defaultSize {
    return CGSizeMake(50, 50);
}

- (id)initWithStartPoint:(CGPoint)point {
    self = [super initWithFrame:CGRectMake(point.x, point.y, [self.class defaultSize].width, [self.class defaultSize].height)];
    if (self) {
        [self initialize];
    }
    return self;
}

- (id)initWithCenter:(CGPoint)center {
    self = [super initWithFrame:CGRectMake(0, 0, [self.class defaultSize].width, [self.class defaultSize].height)];
    if (self) {
        self.center = center;
        [self initialize];
    }
    return self;
}

- (void)initialize {
    self.layer.cornerRadius  = [self.class defaultSize].width/2.0;
    self.layer.masksToBounds = YES;
    self.backgroundColor = [UIColor redColor];
    
    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pointViewPanFrom:)];
    
//    [self.view bringSubviewToFront:whiteSpotsButton];//放到最前面
    
    [self addGestureRecognizer:panRecognizer];//关键语句，添加一个手势监测；
    
    panRecognizer.maximumNumberOfTouches = 1;
    
    panRecognizer.delegate = self;
}

- (void)pointViewPanFrom:(UIPanGestureRecognizer*)recognizer

{
    NSLog(@"拖动操作");
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
